package com.wavehi.login.mapper;

import com.wavehi.login.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/**
 * @Author WaveHi
 * @Date 25/10/2021 下午 7:24
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description CRUD for user information
 */
@Repository
public interface UserMapper {

    /**
     * Insert user information to database
     * @param user User information
     * @return If false is returned, insert fails.
     */
    Boolean insert(User user);

    /**
     * Update user information
     * @param user User information for update.
     * @return If false is returned, update fails or there no such data.
     */
    Boolean update(User user);

    /**
     * Delete user information according to id
     * @param id User  id
     * @return  If false is returned, delete fails or there no such data.
     */
    Boolean delete(Long id);

    /**
     * Query information according to id
     * @param id  User id
     * @return Return an object that encapsulates the specified user information.
     */
    User selectById(Long id);

    /**
     * Query information according to user name.
     * @param username User name
     * @return Return an object that encapsulates the specified user information.
     */
    User selectByUsername(String username);

    /**
     * Query information according to user name and password.
     * @param username User name
     * @param password User password
     * @return Return an object that encapsulates the specified user information.
     */
    User selectByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
}
